<?php
class GeneralReportData extends ORDataObject {
	var $general_report_data_id	=	'';
  	var $report_id				=	'';
  	var $metric_value			=	'';
  	var $data_value				=	'';
  	var	$order					=	'';

  	var	$_table	=	'general_report_data';
  	var	$_key	=	'general_report_data_id';

  	public function setData($reportId, $metric, $data, $order){
  		$data	=	array(
  			'report_id'		=>	$reportId,
  			'metric_value'	=>	$metric,
  			'data_value'	=>	$data,
  			'order'			=>	$order
  		);
  		$this->populateArray($data);
  	}
  	public function getReportId(){
  		return $this->report_id;
  	}

  	public function getMetricValue(){
  		return $this->metric_value;
  	}

  	public function getDataValue(){
  		return $this->data_value;
  	}

  	public function clearData(){
  		$this->general_report_data_id	=	'';
  		$this->report_id				=	'';
  		$this->metric_value				=	'';
  		$this->data_value				=	'';
  		$this->order					=	'';
  	}

  	public function deleteData($reportId){
  		$sql	=	"DELETE FROM $this->_table WHERE report_id=$reportId";
  		$this->_execute($sql);
  	}

  	public function getReportData($reportId){
		$ds		=	&new Datasource_sql();
		$sql	=	array(
			'cols'	=>	"*",
			'from'	=>	"$this->_table",
			'where'	=>	"report_id=$reportId",
			'orderby'	=>	"$this->_table.order ASC"
		);
		$ds->setup($this->_db, $sql);
        $res    =   $ds->toArray();
        $res    =   Utils::trimNumberOfArray($res, 'data_value');

        return $res;
  	}
  }
?>